﻿using System;
using System.Windows;
using System.Windows.Controls;
using NetflixFormsApplication.Presentors;

namespace NetflixFormsApplication.Views
{
    /// <summary>
    /// Interaction logic for MovieWPFSearchView.xaml
    /// </summary>
    public partial class MovieWPFSearchView : UserControl, IMovieSearchView
    {
        
        private readonly MovieSearchPresenter _presenter;

        public MovieWPFSearchView()
        {
            InitializeComponent();
            _presenter = new MovieSearchPresenter(this, new NetflixMovieService.NetflixMovieService());
        }

        private void searchButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                LsImageGallery.DataContext = _presenter.RetrieveMovies(releaseYearTextBox.Text, maxResultSetTextBox.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        public void SendMessage(string message)
        {
            resultsTextBox.Text = message;
        }

        public void ClearView()
        {
            resultsTextBox.Text = String.Empty;
            LsImageGallery.DataContext = null;
        }


        public void AddGridRow(System.Windows.Forms.DataGridViewRow row)
        {
        }

        
    }

    
}
